package com.puzzlebazar.client.heyawake;

import com.puzzlebazar.client.puzzle.model.Move;
import com.puzzlebazar.client.puzzle.model.MoveImpl;
import com.puzzlebazar.client.puzzle.model.PuzzleModel;
import com.puzzlebazar.client.util.Recti;

public abstract class MoveRoom extends MoveImpl {

	/**
	 * 
	 */
	private static final long serialVersionUID = -2188872200758184031L;
	
	private Room room;
	
	/**
	 * Only for serialization
	 */
	protected MoveRoom() {
		super();
	}
	
	/**
	 * Creates a room move
	 * 
	 * @param room The room
	 * @param time The time of this move
	 */
	public MoveRoom( Room room, long time ) {
		super( time );
		this.room = new Room(room);
	}

	/**
	 * @return The room
	 */
	public Room getRoom() {
		return room;
	}
	
	/**
	 * @return The room area
	 */
	public Recti getRoomArea() {
		return room.getRoomArea();
	}

	/**
	 * @return The room value
	 */
	public int getValue() {
		return room.getValue();
	}
	
	/**
	 * Creates a room using the information in the move
	 * 
	 * @param model Mode to create the move in
     * @return A Move List that can be used for a more efficient call to notifyObserver()
	 * @throws Exception
	 */
	protected Move createRoom(PuzzleModel model) throws Exception {
		assert model instanceof HeyawakeModel;
		return ((HeyawakeModel)model).addRoom( room, time );
	}

	/**
	 * Deletes a room using the information in the move
	 * 
	 * @param model Mode to create the move in
     * @return A Move List that can be used for a more efficient call to notifyObserver()
	 * @throws Exception
	 */
	protected Move deleteRoom(PuzzleModel model) throws Exception {
		assert model instanceof HeyawakeModel;
		return ((HeyawakeModel)model).removeRoom( room, time );
	}

}
